<{capture name="header"}>
    <!--JAVASCRIPTS SRC-->
    <{script src="coms/dropmenu.js"  app='desktop'}>
    <{script src="coms/datapicker.js"  app='desktop'}>
    <!--JAVASCRIPTS SRC END-->
<{/capture}>
<{capture name="sidebar"}>
<div class="side-bx spage-side">
    <div class="spage-side-nav">
        <ul>
            <li class="l-handle all" ><span><{if $promotion_type == 'goods'}><{t}>商品促销规则<{/t}><{else}><{t}>订单促销规则<{/t}><{/if}></span></li>
            <{foreach from=$sections item=section name="sec"}>
                <{if $env.foreach.sec.iteration neq 1}>
                <li class="l-handle" ><span><{$section.label}></span></li>
                <{/if}>
            <{/foreach}>
        </ul>
    </div>
</div>

<{/capture}>


<{foreach from=$sections item=section}>
<div class="spage-main-box">
  <{include file=$section.file app=$section.app}>
</div>
<{/foreach}>
<{capture name='footbar'}>
<table cellspacing="0" cellpadding="0" class="table-action">
      <tbody><tr valign="middle">
        <td>
		<{assign var="___a"  value="关  闭"}>
		<{assign var="___c"  value=$___b2c='确定退出?'|t:'b2c'}>
            <{button label=$___b2c="保存并关闭窗口"|t:'b2c' class="btn-primary" onclick="submitForm(event,2)"}>
            <!--<{button label="保  存" class="btn-primary" onclick="submitForm(event,1)"}>-->
            <{button label=$___content=$___a|t:'content' class="btn-secondary" onclick="if(confirm('{$___c}'))window.close()"}>
        </td>
        </tr>
        </tbody>
</table>

<script>
var __radio_name;
var submitForm = function (event,sign){
       var _form=$('promotion_form');
       
       var flag = false;
       
       $ES('input[type=radio]','ctpl_list').each(function(el){
            if( el.get('disabled')!=true ) {
                if(el.checked) flag = el.checked;
            }
        });
        if(!flag) {
            MessageBox.error('<{t}>请选择优惠条件<{/t}>');/*alert('<{t}>请选择过滤条件<{/t}>');*/
            return false;
        }
       
       flag = false;
       $ES('input[type=radio]','stpl_list').each(function(el){
            if( el.get('disabled')!=true ) {
                if(el.checked) flag = el.checked;
            }
        });
        if(!flag) {
            MessageBox.error('<{t}>请选择优惠方案<{/t}>');/*alert('<{t}>请选择过滤条件<{/t}>');*/
            return false;
        }
        
        
        
        
        flag = false;
        $ES('input[type=checkbox]', '#mLev').each(function(item){
            if(item.checked) {
                flag = true;
            }
        });
        if(!flag) {
            MessageBox.error('<{t}>必须选择一项会员级别!<{/t}>');;return false;
        }
        
        
        switch (sign){
            case 1:
            var target={
                    onComplete:function(){
                        location.reload();
                }};
            break;
            case 2:
            var target={
                    onComplete:function(){
                        if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get.finder_id}>']){
                            window.opener.finderGroup['<{$env.get.finder_id}>'].refresh();
                        }
                        window.close();
                    }};
            break;
       }
       _form.store('target',target);
       _form.fireEvent('submit',new Event(event));
    };
</script>
<{/capture}>